import React from 'react';
import actionCreators from '../store/actionCreators/counter1';
import {connect} from 'react-redux';
class Counter1 extends React.Component{
    render(){
        return (
            <div>
                <p>{this.props.number}</p>
                <button onClick={this.props.add1}>+</button>
                <button onClick={this.props.minus1}>-</button>
            </div>
        )
    }
}
//把仓库的总状态映射为当前组件的属性对象 读取仓库中的状态
const mapStateToProps = state=>state.counter1;//{number:0}
//把派发动作的方法映射为属性对象 通过派发动作修改仓库中的状态
const mapDispatchToProps = actionCreators;
//在connect内部会帮我们自动绑定actionCreators
//const boundActionCreators =  bindActionCreators(actionCreators,store.dispatch);
export default connect(
    mapStateToProps,
    actionCreators
)(Counter1)